package com.sto.stoapp.db.manager;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Base64;

import com.sto.stoapp.dataprocess.ProcessTableData;
import com.sto.stoapp.db.StoDataBase;
import com.sto.stoapp.db.StoFilePreference;
import com.sto.stoapp.db.StoTableFieldName;
import com.sto.stoapp.db.StoTableName;
import com.sto.stoapp.http.request.ServerSmsUploadRequest;
import com.sto.stoapp.http.request.upload.ArriveCarInfo;
import com.sto.stoapp.http.request.upload.ArrivePieInfo;
import com.sto.stoapp.http.request.upload.AssignPieceInfo;
import com.sto.stoapp.http.request.upload.AviationArrivePackageInfo;
import com.sto.stoapp.http.request.upload.AviationPackageSendInfo;
import com.sto.stoapp.http.request.upload.AviationSendPackageInfo;
import com.sto.stoapp.http.request.upload.BagOperationInfo;
import com.sto.stoapp.http.request.upload.BagSendPieceInfo;
import com.sto.stoapp.http.request.upload.ConnectInfo;
import com.sto.stoapp.http.request.upload.LeadSealInfo;
import com.sto.stoapp.http.request.upload.LoadingSendInfo;
import com.sto.stoapp.http.request.upload.NetReceivedInfo;
import com.sto.stoapp.http.request.upload.OrderBackRequest;
import com.sto.stoapp.http.request.upload.OrderGainRequest;
import com.sto.stoapp.http.request.upload.PackageOperate;
import com.sto.stoapp.http.request.upload.ProblemInfo;
import com.sto.stoapp.http.request.upload.SalesReceivedInfo;
import com.sto.stoapp.http.request.upload.SendCarInfo;
import com.sto.stoapp.http.request.upload.SendPieceInfo;
import com.sto.stoapp.http.request.upload.SignHelpSmsInfo;
import com.sto.stoapp.http.request.upload.SignInInfo;
import com.sto.stoapp.http.request.upload.StayWarehourseInfo;
import com.sto.stoapp.log.ExceptionLog;
import com.sto.stoapp.status.EnumTableNames;
import com.sto.stoapp.upload.UploadInfoKey;
import com.sto.stoapp.util.Helper;
import com.sto.stoapp.util.TraceUtil;
import com.sto.stoapp.util.UnifiedStaticType;

import org.json.JSONArray;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class UploadDataManager extends StoDataBase {

	private Context context;
	private static UploadDataManager uploadDataManager;

	List<UploadInfoKey> uploadInfoKeys = new ArrayList<UploadInfoKey>();

	private static int maxCount = 20;

	public UploadDataManager(Context context) {
		super(context);
		this.context = context;
	}

	public static UploadDataManager getInstance(Context context) {
		if (uploadDataManager == null) {
			uploadDataManager = new UploadDataManager(context);
		}
		return uploadDataManager;

	}

	@SuppressLint("SimpleDateFormat")
	public List<Object> queryUploadData(EnumTableNames currentList) {
		synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {

			List<Object> bizInfos = new ArrayList<Object>();
			uploadInfoKeys.clear();
			int count = 0;
			StoTableFieldName BusinessField = new StoTableFieldName();
			String tableName = currentList.getTableName();
			String sql = "select * from " + tableName + " where send_state =?";
			String deviceType = "PDA";
			Cursor cursor = getCursor(UnifiedStaticType.READ_DATABASE, sql,
					new String[] { UnifiedStaticType.NO_STATUS });
			while (cursor.moveToNext()) {
				// 命令类型
				String command_type = cursor.getString(cursor
						.getColumnIndex(BusinessField.COMMAND_TYPE));
				// uuid
				String pdaUuid = cursor.getString(cursor
						.getColumnIndex(BusinessField.PDA_UUID));
				// ROLE
				String auxOpCode = cursor.getString(cursor
						.getColumnIndex(BusinessField.AUXOPCODE));
				// AUXOPCODE
				String role = cursor.getString(cursor
						.getColumnIndex(BusinessField.ROLE));
				// EXPTYPE 单号类型
				String expType = cursor.getString(cursor
						.getColumnIndex(BusinessField.EXPTYPE));
				// 输入重量
				String inputWeight = cursor.getString(cursor
						.getColumnIndex(BusinessField.INPUT_WEIGHT));
				// 上下站编号、目的地 /收件员、派件员编号
				String next_station = cursor.getString(cursor
						.getColumnIndex(BusinessField.NEXT_STATION));
				// 袋号/条码铅封
				String bag_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.BAG_NUMBER));
				// 扫描日期 月日年
				String scan_date = cursor.getString(cursor
						.getColumnIndex(BusinessField.SCAN_DATE));
				// 扫描日期 年月日
				String scan_date2 = cursor.getString(cursor
						.getColumnIndex(BusinessField.SCAN_DATE2));

				// 扫描时间
				String scan_time = cursor.getString(cursor
						.getColumnIndex(BusinessField.SCAN_TIME));

				String opTime = scan_date2 + " " + scan_time;
				// 物品类型/功能类别
				String function_type = cursor.getString(cursor
						.getColumnIndex(BusinessField.FUNCTION_TYPE));
				// 快件类型
				String express_type = cursor.getString(cursor
						.getColumnIndex(BusinessField.EXPRESS_TYPE));
				if (express_type == null) {
					express_type = "";
				}
				// 运单编码/包条码/车签条码
				String bar_code_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.BAR_CODE_NUMBER));
				// 扫描员编
				// String scanner_number = cursor.getString(cursor
				// .getColumnIndex(BusinessField.SCANNER_NUMBER));
				// 班次
				String shift = cursor.getString(cursor
						.getColumnIndex(BusinessField.SHIFT));
				// 异常签收原因编号/路由号 订单编号/订单打回原因/width 轻泡货 宽
				String reason_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.REASON_NUMBER));
				// 代收款、车牌号
				// String car_number = cursor.getString(cursor
				// .getColumnIndex(BusinessField.CAR_NUMBER));
				// 货单标识/车牌ID条码/length 轻泡货长
				String carID_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.CARID_NUMBER));
				// 收件人手机号/签收人/同行名称
				String remark_name = cursor.getString(cursor
						.getColumnIndex(BusinessField.REMARK_NAME));
				// 重量
				String weight = cursor.getString(cursor
						.getColumnIndex(BusinessField.WEIGHT));
				// 寄件人手机号
				String send_phone = cursor.getString(cursor
						.getColumnIndex(BusinessField.SEND_PHONE));
				// 巴枪唯一码
				String unique_code = cursor.getString(cursor
						.getColumnIndex(BusinessField.UNIQUE_CODE));
				if (unique_code == null || unique_code.trim().length() == 0) {
					unique_code = StoFilePreference.getInstance(context)
							.getMachineCode();
				}
				// 网点编号
				String net_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.NET_CODE));
				// 工号
				String job_number = cursor.getString(cursor
						.getColumnIndex(BusinessField.JOB_NUMBER));
				if (job_number == null || !Helper.isNumeric(job_number)) {
					job_number = StoFilePreference.getInstance(context)
							.getUserCode();
				}
				String opusercode = net_number + job_number;
				// 收件人 /签收人
				String recv_person = cursor.getString(cursor
						.getColumnIndex(BusinessField.RECV_PERSON));
				// 备注/
				String remark = cursor.getString(cursor
						.getColumnIndex(BusinessField.DIFFERENT_FLAG));
				// 图片路径/
				String defined4 = cursor.getString(cursor
						.getColumnIndex(BusinessField.USER_DEFINED4));
				// 图片文件
				String imageStr = "";
				if (!"".equals(defined4)) {
					try {
						imageStr = getImageString(defined4);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				// 备注/
				String defined5 = cursor.getString(cursor
						.getColumnIndex(BusinessField.USER_DEFINED5));

				 String defined3 = cursor.getString(cursor
				 .getColumnIndex(BusinessField.USER_DEFINED3));
				UploadInfoKey key = new UploadInfoKey();
				key.barCode = bar_code_number;
				key.date2 = scan_date2;
				key.time = scan_time;
				uploadInfoKeys.add(key);
				switch (currentList) {

				// 交接扫描
				case STATUS_TABLE_JOIN_SCAN:
					ConnectInfo connectInfo = new ConnectInfo();
					connectInfo.auxOpCode = auxOpCode;
					connectInfo.clientProgramRole = role;
					connectInfo.opCode = command_type;
					connectInfo.opOrgCode = net_number;
					connectInfo.opTerminal = unique_code;
					connectInfo.opTime = opTime;
					connectInfo.opUserCode = opusercode;
					connectInfo.pdaUuid = pdaUuid;
					connectInfo.expType = expType;
					connectInfo.waybillNo = bar_code_number;
					connectInfo.deviceType = deviceType;
					connectInfo.nextOrgCode = next_station;
					bizInfos.add(connectInfo);
					break;
				// 业务员-收件
				case STATUS_TABLE_SALESMAN_RECEIVE:
					SalesReceivedInfo salesReceivedInfo = new SalesReceivedInfo();
					salesReceivedInfo.auxOpCode = auxOpCode;
					salesReceivedInfo.clientProgramRole = role;
					salesReceivedInfo.opCode = command_type;
					salesReceivedInfo.opOrgCode = net_number;
					salesReceivedInfo.opTerminal = unique_code;
					salesReceivedInfo.opTime = opTime;
					salesReceivedInfo.opUserCode = opusercode;
					salesReceivedInfo.pdaUuid = pdaUuid;
					salesReceivedInfo.expType = expType;
					salesReceivedInfo.waybillNo = bar_code_number;
					salesReceivedInfo.deviceType = deviceType;

					salesReceivedInfo.desAreaCode = next_station;
					salesReceivedInfo.effectiveType = express_type;
					salesReceivedInfo.goodsType = function_type;
					salesReceivedInfo.orderNo = reason_number;
					salesReceivedInfo.receiveMobilePhone = remark_name;
					salesReceivedInfo.sendMobilePhone = send_phone;

					bizInfos.add(salesReceivedInfo);
					break;

				// 业务员-签收
				case STATUS_TABLE_SALESMAN_SIGN:

					SignInInfo signInInfo = new SignInInfo();
					signInInfo.auxOpCode = auxOpCode;
					signInInfo.clientProgramRole = role;
					signInInfo.opCode = command_type;
					signInInfo.opOrgCode = net_number;
					signInInfo.opTerminal = unique_code;
					signInInfo.opTime = opTime;
					signInInfo.opUserCode = opusercode;
					signInInfo.pdaUuid = pdaUuid;
					signInInfo.expType = expType;
					signInInfo.waybillNo = bar_code_number;
					signInInfo.deviceType = deviceType;

					signInInfo.recieverSignoff = recv_person;
					signInInfo.signoffImg = imageStr;
					signInInfo.empCode = opusercode;
					bizInfos.add(signInInfo);

					break;

				//Add by wj 代收签收短信数据
				case STATUS_TABLE_SALESMAN_HELP_SIGN:

					SignHelpSmsInfo signHelpSmsInfo=new SignHelpSmsInfo();
					signHelpSmsInfo.waybillNo=bar_code_number;
					signHelpSmsInfo.opTime= opTime;
					signHelpSmsInfo.optime=opTime;
					signHelpSmsInfo.signUser=recv_person;
					signHelpSmsInfo.mobilephone=send_phone;
					bizInfos.add(signHelpSmsInfo);

					break;
				//End by wj

				// 航空-扫描-问题件
				case STATUS_TABLE_AVIATION_PROBLEM:
					// 问题件
				case STATUS_TABLE_PROBLEM:

					ProblemInfo ProblemInfo = new ProblemInfo();
					ProblemInfo.auxOpCode = auxOpCode;
					ProblemInfo.clientProgramRole = role;
					ProblemInfo.opCode = command_type;
					ProblemInfo.opOrgCode = net_number;
					ProblemInfo.opTerminal = unique_code;
					ProblemInfo.opTime = opTime;
					ProblemInfo.opUserCode = opusercode;
					ProblemInfo.pdaUuid = pdaUuid;
					ProblemInfo.expType = expType;
					ProblemInfo.waybillNo = bar_code_number;
					ProblemInfo.deviceType = deviceType;

					ProblemInfo.effectiveType = express_type;
					ProblemInfo.frequencyNo = shift;
					ProblemInfo.goodsType = function_type;
					ProblemInfo.issueImg = imageStr;
					ProblemInfo.issueType = reason_number;
					bizInfos.add(ProblemInfo);

					break;

				// 订单提取
				case STATUS_TABLE_SALESMAN_ORDER_EXTRACT:// 改成一条发

					OrderGainRequest orderGainRequest = new OrderGainRequest();
					orderGainRequest.deviceType = deviceType;
					orderGainRequest.mty = "0" + command_type;
					orderGainRequest.oderNo = reason_number;
					orderGainRequest.opOrgCode = net_number;
					orderGainRequest.opTerminal = unique_code;
					orderGainRequest.opTime = opTime;
					orderGainRequest.opUserCode = opusercode;
					orderGainRequest.org = net_number;
					orderGainRequest.receiveWaybillNo = bar_code_number;
					orderGainRequest.sessionId = StoFilePreference.getInstance(
							context).getSessionId();
					orderGainRequest.tid = StoFilePreference.getInstance(
							context).getMachineCode();
					orderGainRequest.trace = TraceUtil.getTraceTimes();
					bizInfos.add(orderGainRequest);

					break;

				// 订单打回
				case STATUS_TABLE_SALESMAN_ORDER_BACK:// 改成一条发

					OrderBackRequest orderBackRequest = new OrderBackRequest();
					orderBackRequest.opCode = command_type;
					orderBackRequest.opOrgCode = net_number;
					orderBackRequest.opTerminal = unique_code;
					orderBackRequest.opTime = opTime;
					orderBackRequest.opUserCode = opusercode;
					orderBackRequest.deviceType = deviceType;
					orderBackRequest.mty = "0" + command_type;
					orderBackRequest.oderNo = bar_code_number;
					orderBackRequest.org = net_number;
					orderBackRequest.rollbackReason = reason_number;
					orderBackRequest.rollbackTime = opTime;
					orderBackRequest.tid = unique_code;
					orderBackRequest.trace = TraceUtil.getTraceTimes();
					orderBackRequest.sessionId = StoFilePreference.getInstance(
							context).getSessionId();

					bizInfos.add(orderBackRequest);

					break;

				// 服务点短信
				case STATUS_TABLE_SERVICE_SMS:
					break;

				// 扫描员-收件(网点收件)
				case STATUS_TABLE_SCANNING_RECEIVE:
					NetReceivedInfo netReceivedInfo = new NetReceivedInfo();
					netReceivedInfo.auxOpCode = auxOpCode;
					netReceivedInfo.clientProgramRole = role;
					netReceivedInfo.opCode = command_type;
					netReceivedInfo.opOrgCode = net_number;
					netReceivedInfo.opTerminal = unique_code;
					netReceivedInfo.opTime = opTime;
					netReceivedInfo.opUserCode = opusercode;
					netReceivedInfo.pdaUuid = pdaUuid;
					netReceivedInfo.empCode = recv_person;
					netReceivedInfo.expType = expType;
					netReceivedInfo.waybillNo = bar_code_number;
					netReceivedInfo.deviceType = deviceType;
					netReceivedInfo.effectiveType = express_type;
					netReceivedInfo.desAreaCode = next_station;
					netReceivedInfo.goodsType = function_type;
					netReceivedInfo.input_weight = inputWeight;
					netReceivedInfo.weight = weight;
					bizInfos.add(netReceivedInfo);
					break;
				// 扫描员-发件
				case STATUS_TABLE_SCANNING_SENDPIECE:
					// 航空-扫描-发件
				case STATUS_TABLE_AVIATION_SCAN_SEND:
					// 中转 - 发件
				case STATUS_TABLE_CENTER_SENDPIECE:

					SendPieceInfo sendpieceInfo = new SendPieceInfo();
					sendpieceInfo.auxOpCode = auxOpCode;
					sendpieceInfo.clientProgramRole = role;
					sendpieceInfo.opCode = command_type;
					sendpieceInfo.opOrgCode = net_number;
					sendpieceInfo.opTerminal = unique_code;
					sendpieceInfo.opTime = opTime;
					sendpieceInfo.opUserCode = opusercode;
					sendpieceInfo.pdaUuid = pdaUuid;
					sendpieceInfo.expType = expType;
					sendpieceInfo.waybillNo = bar_code_number;
					sendpieceInfo.deviceType = deviceType;

					sendpieceInfo.goodsType = function_type;
					sendpieceInfo.nextOrgCode = next_station;
					sendpieceInfo.routeCode = reason_number;
					sendpieceInfo.vehicleId = carID_number;
					sendpieceInfo.weight = weight;
					sendpieceInfo.frequencyNo = shift;
					sendpieceInfo.effectiveType = express_type;

					bizInfos.add(sendpieceInfo);
					break;

				// 航空-扫描-到件
				case STATUS_TABLE_AVIATION_SCAN_TO_PIECE:
					// 中转 - 到件
				case STATUS_TABLE_CENTER_REACHPIECE:
					// 扫描员-到件
				case STATUS_TABLE_SCANNING_REACHPIECE:
					ArrivePieInfo arrivePieInfo = new ArrivePieInfo();
					arrivePieInfo.auxOpCode = auxOpCode;
					arrivePieInfo.clientProgramRole = role;
					arrivePieInfo.opCode = command_type;
					arrivePieInfo.opOrgCode = net_number;
					arrivePieInfo.opTerminal = unique_code;
					arrivePieInfo.opTime = opTime;
					arrivePieInfo.opUserCode = opusercode;
					arrivePieInfo.pdaUuid = pdaUuid;
					arrivePieInfo.expType = expType;
					arrivePieInfo.waybillNo = bar_code_number;
					arrivePieInfo.deviceType = deviceType;
					arrivePieInfo.goodsType = function_type;
					arrivePieInfo.lastOrgCode = next_station;
					arrivePieInfo.effectiveType = express_type;
					arrivePieInfo.frequencyNo = shift;
					arrivePieInfo.weight = weight;
					arrivePieInfo.inputWeight = inputWeight;
					arrivePieInfo.width = reason_number;
					arrivePieInfo.length = defined3;
					arrivePieInfo.height = defined4;
					arrivePieInfo.volume = defined5;
					bizInfos.add(arrivePieInfo);

					break;

				// 扫描员-派件
				case STATUS_TABLE_SCANNING_ASSIGNPIECE:
					AssignPieceInfo assignPieceInfo = new AssignPieceInfo();
					assignPieceInfo.auxOpCode = auxOpCode;
					assignPieceInfo.clientProgramRole = role;
					assignPieceInfo.opCode = command_type;
					assignPieceInfo.opOrgCode = net_number;
					assignPieceInfo.opTerminal = unique_code;
					assignPieceInfo.opTime = opTime;
					assignPieceInfo.opUserCode = opusercode;
					assignPieceInfo.pdaUuid = pdaUuid;
					assignPieceInfo.expType = expType;
					assignPieceInfo.waybillNo = bar_code_number;
					assignPieceInfo.deviceType = deviceType;
					assignPieceInfo.effective = express_type;
					assignPieceInfo.goodsType = function_type;
					assignPieceInfo.empCode = next_station;
					bizInfos.add(assignPieceInfo);
					break;

				// 航空-扫描-留仓件
				case STATUS_TABLE_AVIATION_STAY_WAREHOURSE:
					// 中转-留仓件
				case STATUS_TABLE_CENTER_STAY_WAREHOURSE:
					// 留仓件
				case STATUS_TABLE_STAY_WAREHOURSE:
					StayWarehourseInfo stayWarehourseInfo = new StayWarehourseInfo();
					stayWarehourseInfo.auxOpCode = auxOpCode;
					stayWarehourseInfo.clientProgramRole = role;
					stayWarehourseInfo.opCode = command_type;
					stayWarehourseInfo.opOrgCode = net_number;
					stayWarehourseInfo.opTerminal = unique_code;
					stayWarehourseInfo.opTime = opTime;
					stayWarehourseInfo.opUserCode = opusercode;
					stayWarehourseInfo.pdaUuid = pdaUuid;
					stayWarehourseInfo.expType = expType;
					stayWarehourseInfo.waybillNo = bar_code_number;
					stayWarehourseInfo.deviceType = deviceType;
					stayWarehourseInfo.effectiveType = express_type;
					stayWarehourseInfo.frequencyNo = shift;
					stayWarehourseInfo.goodsType = function_type;

					stayWarehourseInfo.empCode = next_station;
					bizInfos.add(stayWarehourseInfo);
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// function_type, next_station, net_number,
					// job_number, carID_number, weight, unique_code,
					// remark).toString();
					break;
				// 中转-装袋发件
				case STATUS_TABLE_CENTER_BAGGINGADNSENDPIECE:
					// 装袋&发件
				case STATUS_TABLE_BAGGINGADNSENDPIECE:
					BagSendPieceInfo bagSendPieceInfo = new BagSendPieceInfo();
					bagSendPieceInfo.auxOpCode = auxOpCode;
					bagSendPieceInfo.clientProgramRole = role;
					bagSendPieceInfo.opCode = command_type;
					bagSendPieceInfo.opOrgCode = net_number;
					bagSendPieceInfo.opTerminal = unique_code;
					bagSendPieceInfo.opTime = opTime;
					bagSendPieceInfo.opUserCode = opusercode;
					bagSendPieceInfo.pdaUuid = pdaUuid;
					bagSendPieceInfo.expType = expType;
					bagSendPieceInfo.waybillNo = bar_code_number;
					bagSendPieceInfo.deviceType = deviceType;
					bagSendPieceInfo.containerNo = bag_number;
					// ?
					bagSendPieceInfo.nextOrgCode = next_station;
					bagSendPieceInfo.vehicleId = carID_number;

					bizInfos.add(bagSendPieceInfo);
					break;
				// 航空-扫描-包操作-装包&发件
				case STATUS_TABLE_AVIATION_SCAN_PACKET_SEND:
					AviationPackageSendInfo aviationPackageSendInfo = new AviationPackageSendInfo();
					aviationPackageSendInfo.auxOpCode = auxOpCode;
					aviationPackageSendInfo.clientProgramRole = role;
					aviationPackageSendInfo.opCode = command_type;
					aviationPackageSendInfo.opOrgCode = net_number;
					aviationPackageSendInfo.opTerminal = unique_code;
					aviationPackageSendInfo.opTime = opTime;
					aviationPackageSendInfo.opUserCode = opusercode;
					aviationPackageSendInfo.pdaUuid = pdaUuid;
					aviationPackageSendInfo.expType = expType;
					aviationPackageSendInfo.waybillNo = bar_code_number;
					aviationPackageSendInfo.deviceType = deviceType;
					aviationPackageSendInfo.containerNo = bag_number;
					aviationPackageSendInfo.routeCode = reason_number;
					aviationPackageSendInfo.vehicleId = carID_number;
					aviationPackageSendInfo.goodsType = function_type;

					bizInfos.add(aviationPackageSendInfo);
					// if ("A".equals(express_type)) {
					// express_type = "1             0";
					// } else if ("B".equals(express_type)) {
					// express_type = "              0";
					// }
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// plusString(bag_number, 15) + function_type,
					// reason_number, net_number, job_number, // bag_number
					// carID_number, weight, unique_code, express_type) //
					// remark
					// .toString();
					break;
				// 中转-装车发件
				case STATUS_TABLE_CENTER_LOADCAR_SENDPIECE:
					/*
					 * // 航空-扫描-装车发件 case
					 * STATUS_TABLE_AVIATION_LOADCAR_SENDPIECE:
					 */
					// 装车发件
				case STATUS_TABLE_LOADCAR_SENDPIECE:

					LoadingSendInfo loadingSendInfo = new LoadingSendInfo();
					loadingSendInfo.auxOpCode = auxOpCode;
					loadingSendInfo.clientProgramRole = role;
					loadingSendInfo.opCode = command_type;
					loadingSendInfo.opOrgCode = net_number;
					loadingSendInfo.opTerminal = unique_code;
					loadingSendInfo.opTime = opTime;
					loadingSendInfo.opUserCode = opusercode;
					loadingSendInfo.pdaUuid = pdaUuid;
					loadingSendInfo.expType = expType;
					loadingSendInfo.waybillNo = bar_code_number;
					loadingSendInfo.deviceType = deviceType;
					loadingSendInfo.backGateSealNo = bag_number;
					loadingSendInfo.nextOrgCode = next_station;
					loadingSendInfo.routeCode = "";
					bizInfos.add(loadingSendInfo);
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// bag_number, "", net_number, job_number,
					// carID_number, weight, unique_code, remark)
					// .toString();
					break;
				// 航空-扫描-装车发件
				case STATUS_TABLE_AVIATION_LOADCAR_SENDPIECE:
					loadingSendInfo = new LoadingSendInfo();
					loadingSendInfo.auxOpCode = auxOpCode;
					loadingSendInfo.clientProgramRole = role;
					loadingSendInfo.opCode = command_type;
					loadingSendInfo.opOrgCode = net_number;
					loadingSendInfo.opTerminal = unique_code;
					loadingSendInfo.opTime = opTime;
					loadingSendInfo.opUserCode = opusercode;
					loadingSendInfo.pdaUuid = pdaUuid;
					loadingSendInfo.expType = expType;
					loadingSendInfo.waybillNo = bar_code_number;
					loadingSendInfo.deviceType = deviceType;
					loadingSendInfo.backGateSealNo = bag_number;
					loadingSendInfo.nextOrgCode = next_station;
					loadingSendInfo.routeCode = reason_number;
					bizInfos.add(loadingSendInfo);
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// bag_number, reason_number, net_number, job_number,
					// carID_number, weight, unique_code, express_type) //
					// remark
					// .toString();
					break;
				// 中转发车扫描
				case STATUS_TABLE_CENTER_SEND_CAR:
					// 发车扫描
				case STATUS_TABLE_SEND_CAR:
					// 航空-扫描-发车扫描
				case STATUS_TABLE_AVIATION_SEND_CAR:
					SendCarInfo sendCarInfo = new SendCarInfo();
					sendCarInfo.auxOpCode = auxOpCode;
					sendCarInfo.clientProgramRole = role;
					sendCarInfo.opCode = command_type;
					sendCarInfo.opOrgCode = net_number;
					sendCarInfo.opTerminal = unique_code;
					sendCarInfo.opTime = opTime;
					sendCarInfo.opUserCode = opusercode;
					sendCarInfo.pdaUuid = pdaUuid;
					sendCarInfo.backGateSealNo = bar_code_number;

					//Add by wj
					sendCarInfo.waybillNo=bar_code_number;
					//End by wj

					sendCarInfo.deviceType = deviceType;
					sendCarInfo.nextOrgCode = next_station;
					sendCarInfo.vehicleId = carID_number;
					bizInfos.add(sendCarInfo);
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// bag_number, next_station, net_number, job_number,
					// carID_number, weight, unique_code, remark)
					// .toString();
					break;
				// 中转到车扫描
				case STATUS_TABLE_CENTER_RECEIVE_CAR:
					// 到车扫描
				case STATUS_TABLE_RECEIVE_CAR:
					// 航空-扫描-到车扫描
				case STATUS_TABLE_AVIATION_RECEIVE_CAR:

					ArriveCarInfo arriveCarInfo = new ArriveCarInfo();
					arriveCarInfo.auxOpCode = auxOpCode;
					arriveCarInfo.clientProgramRole = role;
					arriveCarInfo.opCode = command_type;
					arriveCarInfo.opOrgCode = net_number;
					arriveCarInfo.opTerminal = unique_code;
					arriveCarInfo.opTime = opTime;
					arriveCarInfo.opUserCode = opusercode;
					arriveCarInfo.pdaUuid = pdaUuid;
					arriveCarInfo.backGateSealNo = bar_code_number;
					//Add by wj
					arriveCarInfo.waybillNo=bar_code_number;
					//End by wj
					arriveCarInfo.deviceType = deviceType;
					bizInfos.add(arriveCarInfo);
					// Data = new ScanReceiveRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// bag_number, next_station, net_number, job_number,
					// carID_number, weight, unique_code, remark)
					// .toString();
					break;
				// 航空提货员到包扫描
				case STATUS_TABLE_AVIATION_PICKER_PACKET:
					AviationArrivePackageInfo aviationArrivePackageInfo = new AviationArrivePackageInfo();
					aviationArrivePackageInfo.auxOpCode = auxOpCode;
					aviationArrivePackageInfo.clientProgramRole = role;
					aviationArrivePackageInfo.opCode = command_type;
					aviationArrivePackageInfo.opOrgCode = net_number;
					aviationArrivePackageInfo.opTerminal = unique_code;
					aviationArrivePackageInfo.opTime = opTime;
					aviationArrivePackageInfo.opUserCode = opusercode;
					aviationArrivePackageInfo.pdaUuid = pdaUuid;
					aviationArrivePackageInfo.expType = expType;
					aviationArrivePackageInfo.waybillNo = bar_code_number;
					aviationArrivePackageInfo.deviceType = deviceType;
					aviationArrivePackageInfo.routeCode = reason_number;

					bizInfos.add(aviationArrivePackageInfo);
					// Data = new AviationArrivedBagRequest(command_type,
					// bar_code_number, scan_time + " " + scan_date,
					// reason_number, next_station, net_number,
					// job_number, "", "", unique_code, remark).toString();
					break;
				// 航空-扫描-包操作-发包
				case STATUS_TABLE_AVIATION_SCAN_SEND_BAG:
					AviationSendPackageInfo aviationSendPackageInfo = new AviationSendPackageInfo();
					aviationSendPackageInfo.auxOpCode = auxOpCode;
					aviationSendPackageInfo.clientProgramRole = role;
					aviationSendPackageInfo.opCode = command_type;
					aviationSendPackageInfo.opOrgCode = net_number;
					aviationSendPackageInfo.opTerminal = unique_code;
					aviationSendPackageInfo.opTime = opTime;
					aviationSendPackageInfo.opUserCode = opusercode;
					aviationSendPackageInfo.pdaUuid = pdaUuid;
					aviationSendPackageInfo.expType = expType;
					aviationSendPackageInfo.waybillNo = bar_code_number;
					aviationSendPackageInfo.deviceType = deviceType;
					aviationSendPackageInfo.routeCode = reason_number;
					bizInfos.add(aviationSendPackageInfo);
					// if ("A".equals(express_type)) {
					// express_type = "1             0";
					// } else if ("B".equals(express_type)) {
					// express_type = "              0";
					// }
					// Data = new ScanReceiveRequest(command_type, bag_number,
					// scan_time + " " + scan_date,
					// plusString(reason_number, 15) + function_type,//
					// reason_number
					// next_station, net_number, job_number, carID_number,
					// weight, unique_code, express_type).toString();
					break;
				// 航空-扫描-包操作-到包
				case STATUS_TABLE_AVIATION_SCAN_ARRIVED_BAG:
					aviationArrivePackageInfo = new AviationArrivePackageInfo();
					aviationArrivePackageInfo.auxOpCode = auxOpCode;
					aviationArrivePackageInfo.clientProgramRole = role;
					aviationArrivePackageInfo.opCode = command_type;
					aviationArrivePackageInfo.opOrgCode = net_number;
					aviationArrivePackageInfo.opTerminal = unique_code;
					aviationArrivePackageInfo.opTime = opTime;
					aviationArrivePackageInfo.opUserCode = opusercode;
					aviationArrivePackageInfo.pdaUuid = pdaUuid;
					aviationArrivePackageInfo.expType = expType;
					aviationArrivePackageInfo.waybillNo = bar_code_number;
					aviationArrivePackageInfo.deviceType = deviceType;
					aviationArrivePackageInfo.routeCode = reason_number;

					bizInfos.add(aviationArrivePackageInfo);
					// Data = new ScanReceiveRequest(command_type, bag_number,
					// scan_time + " " + scan_date, reason_number,
					// next_station, net_number, job_number, carID_number,
					// weight, unique_code, remark).toString();
					break;
				// 扫描员袋操作
				case STATUS_TABLE_SCANNING_BAGGING_OPERATE:

				case STATUS_CENTER_TABLE_BAGGING_OPERATE:
					BagOperationInfo bagOperationInfo = new BagOperationInfo();
					bagOperationInfo.auxOpCode = auxOpCode;
					bagOperationInfo.clientProgramRole = role;
					bagOperationInfo.opCode = command_type;
					bagOperationInfo.opOrgCode = net_number;
					bagOperationInfo.opTerminal = unique_code;
					bagOperationInfo.opTime = opTime;
					bagOperationInfo.opUserCode = opusercode;
					bagOperationInfo.pdaUuid = pdaUuid;
					bagOperationInfo.expType = expType;
					bagOperationInfo.waybillNo = bar_code_number;
					bagOperationInfo.deviceType = deviceType;
					bagOperationInfo.nextOrgCode = next_station;
					bagOperationInfo.vehicleId = carID_number;
					bizInfos.add(bagOperationInfo);
					break;
				// 铅封操作
				case STATUS_TABLE_SCANNING_LEAD_SEALING_OPERATE:
				case STATUS_TABLE_AVIATION_LEAD_SEALING_OPERATE:
				case STATUS_TABLE_CENTER_LEAD_SEALING_OPERATE:

					LeadSealInfo leadSealInfo = new LeadSealInfo();
					leadSealInfo.auxOpCode = auxOpCode;
					leadSealInfo.clientProgramRole = role;
					leadSealInfo.opCode = command_type;
					leadSealInfo.opOrgCode = net_number;
					leadSealInfo.opTerminal = unique_code;
					leadSealInfo.opTime = opTime;
					leadSealInfo.opUserCode = opusercode;
					leadSealInfo.pdaUuid = pdaUuid;
					leadSealInfo.expType = expType;
					leadSealInfo.waybillNo = bar_code_number;
					leadSealInfo.deviceType = deviceType;
					leadSealInfo.nextOrgCode = next_station;
					leadSealInfo.routeCode = reason_number;
					bizInfos.add(leadSealInfo);
					break;
				// 包操作
				case STATUS_TABLE_AVIATION_PACKAGE_OPERATE:
					PackageOperate packageOperate = new PackageOperate();
					packageOperate.auxOpCode = auxOpCode;
					packageOperate.clientProgramRole = role;
					packageOperate.opCode = command_type;
					packageOperate.opOrgCode = net_number;
					packageOperate.opTerminal = unique_code;
					packageOperate.opTime = opTime;
					packageOperate.opUserCode = opusercode;
					packageOperate.pdaUuid = pdaUuid;
					packageOperate.expType = expType;
					packageOperate.waybillNo = bar_code_number;
					packageOperate.deviceType = deviceType;
					packageOperate.containerNo = "";
					packageOperate.goodsType = function_type;
					packageOperate.routeCode = reason_number;
					packageOperate.vehicleId = carID_number;
					bizInfos.add(packageOperate);
					break;
				default:
					break;
				}
				count++;
				/*
				 * @修改内容： 订单提取和打回一条条发送数据
				 * 
				 * @修改人： mgf
				 */
				if (currentList == EnumTableNames.STATUS_TABLE_SALESMAN_ORDER_EXTRACT
						|| currentList == EnumTableNames.STATUS_TABLE_SALESMAN_ORDER_BACK) {
					break;
				}
				if (count >= maxCount)
					break;
			}
			closeCursor(cursor);
			closeDb(UnifiedStaticType.READ_DATABASE);

			return bizInfos;

		}
	}

	@SuppressLint("SimpleDateFormat")
	public String queryUploadSmsData(EnumTableNames currentList) {
		synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
			int count = 0;
			String Data = null;
			Cursor cursor = null;
			try {
				uploadInfoKeys.clear();
				StoTableFieldName BusinessField = new StoTableFieldName();
				String tableName = currentList.getTableName();
				String sql = "select * from " + tableName
						+ " where send_state =?";

				cursor = getCursor(UnifiedStaticType.READ_DATABASE, sql,
						new String[] { UnifiedStaticType.NO_STATUS });

				JSONArray jsonArray = new JSONArray();

				while (cursor.moveToNext()) {

					// 服务点代码
					String next_station = cursor.getString(cursor
							.getColumnIndex(BusinessField.NEXT_STATION));

					// 运单编码/
					String bar_code_number = cursor.getString(cursor
							.getColumnIndex(BusinessField.BAR_CODE_NUMBER));

					// 手机号
					String remark_name = cursor.getString(cursor
							.getColumnIndex(BusinessField.REMARK_NAME));

					// 网点编号
					String net_number = cursor.getString(cursor
							.getColumnIndex(BusinessField.NET_CODE));
					// 扫描日期 年月日
					String scan_date2 = cursor.getString(cursor
							.getColumnIndex(BusinessField.SCAN_DATE2));

					// 扫描时间
					String scan_time = cursor.getString(cursor
							.getColumnIndex(BusinessField.SCAN_TIME));
					UploadInfoKey key = new UploadInfoKey();
					key.barCode = bar_code_number;
					key.date2 = scan_date2;
					key.time = scan_time;
					uploadInfoKeys.add(key);
					switch (currentList) {
					// 服务点短信
					case STATUS_TABLE_SERVICE_SMS:
						ServerSmsUploadRequest request = new ServerSmsUploadRequest(
								bar_code_number, remark_name, net_number,
								next_station);

						jsonArray.put(request.getDataMap());
						break;

					default:
						break;
					}
					count++;
					if (count >= maxCount)
						break;
				}
				Data = jsonArray.toString();

				closeCursor(cursor);
				closeDb(UnifiedStaticType.READ_DATABASE);
			} catch (Exception e) {
				e.printStackTrace();
				ExceptionLog.writeLog("queryUploadSmsData", e.getMessage());
			} finally {
				closeCursor(cursor);
				closeDb(UnifiedStaticType.READ_DATABASE);
			}

			return Data;

		}
	}

	@SuppressLint("SimpleDateFormat")
	// public byte[] queryUploadOrderData(EnumTableNames currentList) {
	// synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
	// String Data = null;
	// int count = 0;
	// StringBuilder sendData = new StringBuilder();
	// listCode.clear();
	//
	// String sql = "select * from " + ORDER_RESPONSE_TABLE
	// + " where status =?";
	//
	// Cursor cursor = getCursor(UnifiedStaticType.READ_DATABASE, sql,
	// new String[] { "0" });
	//
	// while (cursor.moveToNext()) {
	//
	// // 工号
	// String jobNumber = cursor.getString(cursor
	// .getColumnIndex(PICKUP_MEMBERS));
	//
	// // 网点编号
	// String siteCode = cursor.getString(cursor
	// .getColumnIndex(PICKUP_NETWORK));
	//
	// // 订单号
	// String orderCode = cursor.getString(cursor
	// .getColumnIndex(ORDER_NUMBER));
	//
	// // 巴枪唯一码
	// String Unique = cursor.getString(cursor
	// .getColumnIndex(CLIENT_NUMBER));
	//
	// listCode.add(orderCode);
	//
	// /*
	// * switch (currentList) { // 订单回应 case
	// * STATUS_TABLE_ORDER_RESPONSE:
	// */
	// if (count == 0) {
	// Data = new OrderRespRequest("", siteCode, jobNumber, "",
	// orderCode, StoFilePreference.getInstance(context)
	// .getMachineCode()).toString();
	//
	// } else {
	// Data += (orderCode + (",") + Unique + "\r\n");
	//
	// }
	// /*
	// * break;
	// *
	// * default: break; }
	// */
	//
	// count++;
	//
	// if (count >= maxCount)
	// break;
	// }
	//
	// sendData.append(Data);
	//
	// StringBuilder allsendData = new StringBuilder();
	//
	// appendData(allsendData, 4, sendData.toString());
	//
	// allsendData.append("|");
	// allsendData.append(sendData);
	//
	// byte[] str = null;
	// try {
	//
	// str = allsendData.toString().getBytes("gbk");
	//
	// } catch (UnsupportedEncodingException e) {
	// e.printStackTrace();
	// ExceptionLog.writeLog("queryOrderData", e.getMessage());
	// }
	//
	// closeCursor(cursor);
	// closeDb(UnifiedStaticType.READ_DATABASE);
	//
	// return str;
	//
	// }
	// }
	// 添加数据
	private void appendData(StringBuilder result, int count, String replace) {
		try {
			int length = replace.getBytes("GBK").length;
			int i = count - String.valueOf(length).length();
			if (i < 0) {
				result.append(String.valueOf("9999"));
			} else {
				result.append(String.valueOf(length));
			}
			while (i-- > 0) {
				result.append(" ");
			}
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			ExceptionLog.writeLog("appendData", e.getMessage());
		}
	}

	public int UpdateSendState(EnumTableNames currentStatus) {

		int count = uploadInfoKeys.size();
		SimpleDateFormat sDateFormat = new SimpleDateFormat(
				"yyyy/MM/dd HH:mm:ss");
		String date = sDateFormat.format(new java.util.Date());
		StoTableFieldName tableFieldName = new StoTableFieldName();
		String tableName = currentStatus.getTableName();
		String sql = "update " + tableName + " set "
				+ tableFieldName.SEND_STATE + " = ? , "
				+ tableFieldName.UPLOAD_TIME + " = ? " + " where "
				+ tableFieldName.BAR_CODE_NUMBER + " = ?" + " and "
				+ tableFieldName.SEND_STATE + " = ?" + " and "
				+ tableFieldName.SCAN_DATE2 + " =?" + " and "
				+ tableFieldName.SCAN_TIME + " =?";
		synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
			SQLiteDatabase db = getSqliteDatabase(UnifiedStaticType.WRITE_DATABASE);
			try {
				db.beginTransaction();
				for (int i = 0; i < count; i++) {
					UploadInfoKey key = uploadInfoKeys.get(i);
					db.execSQL(sql, new Object[] {
							UnifiedStaticType.YES_STATUS, date, key.barCode,
							UnifiedStaticType.NO_STATUS, key.date2, key.time });
				}

			} catch (Exception e) {
				e.printStackTrace();
				count = 0;
				ExceptionLog.writeLog("UpdateSendState", e.getMessage());
			} finally {
				db.setTransactionSuccessful();
				db.endTransaction();
				closeDb(UnifiedStaticType.WRITE_DATABASE);

			}

			return count;
		}
	}

	/**
	 * 删除一条数据
	 * 
	 * @param
	 * @param
	 * @return
	 */
	// public int UpdateDeleteOrder(EnumTableNames currentStatus) {
	//
	// int count = listCode.size();
	//
	// String sql = "DELETE FROM " + ORDER_RESPONSE_TABLE + " where "
	// + ORDER_NUMBER + " = ?";
	//
	// ExceptionLog.writeLog(" Update  order_response : ", "" + count);
	//
	// synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
	// SQLiteDatabase db = getSqliteDatabase(UnifiedStaticType.WRITE_DATABASE);
	// try {
	// db.beginTransaction();
	// for (int i = 0; i < count; i++) {
	// db.execSQL(sql, new Object[] { listCode.get(i) });
	// }
	//
	// } catch (Exception e) {
	// e.printStackTrace();
	// count = 0;
	// ExceptionLog.writeLog("UpdateDeleteOrder", e.getMessage());
	// } finally {
	// db.setTransactionSuccessful();
	// db.endTransaction();
	// closeDb(UnifiedStaticType.WRITE_DATABASE);
	//
	// }
	//
	// return count;
	// }
	// }

	public int UpdateAgainUploadStatus(EnumTableNames currentStatus, String date) {
		int count = 0;
		StoTableFieldName tableFieldName = new StoTableFieldName();
		String tableName = currentStatus.getTableName();
		/*
		 * String sql = "update " + tableName + " set " +
		 * tableFieldName.SEND_STATE + " = ? " + " where " +
		 * tableFieldName.SCAN_DATE + " = ?" + " and " +
		 * tableFieldName.SEND_STATE + " = ?";
		 */
		synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
			SQLiteDatabase db = getSqliteDatabase(UnifiedStaticType.WRITE_DATABASE);
			try {
				db.beginTransaction();
				String[] args = { date, UnifiedStaticType.YES_STATUS };
				ContentValues cv = new ContentValues();
				cv.put(tableFieldName.SEND_STATE, UnifiedStaticType.NO_STATUS);

				count = db.update(tableName, cv, tableFieldName.SCAN_DATE
						+ " = ? and " + tableFieldName.SEND_STATE + " = ?",
						args);
				/*
				 * db.execSQL(sql, new Object[] { UnifiedStaticType.NO_STATUS,
				 * date, UnifiedStaticType.YES_STATUS });
				 */
				// System.out.println("db.update count:" + count);
			} catch (Exception e) {
				e.printStackTrace();
				ExceptionLog
						.writeLog("UpdateAgainUploadStatus", e.getMessage());
			} finally {
				db.setTransactionSuccessful();
				db.endTransaction();
				closeDb(UnifiedStaticType.WRITE_DATABASE);
			}

			return count;
		}
	}

	public int StatisticsUnsendDataCount(EnumTableNames currentStatus) {
		int count = 0;
		if (currentStatus.ordinal() < EnumTableNames.values().length) {
			try {
				synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {
					StoTableName stoTableName = new StoTableName();
					// Log.d("stoLog", "getUnsendDataCount : " +
					// currentStatus.ordinal());

					String tableName = currentStatus.getTableName();

					String cmd = ("select count(*) from " + tableName + " where send_state = ? and metadata='1'");
					Cursor c = getCursor(UnifiedStaticType.READ_DATABASE, cmd,
							new String[] { UnifiedStaticType.NO_STATUS });
					if (c != null) {
						if (c.moveToFirst()) {
							count = c.getInt(0);
						}
						closeCursor(c);
					}
					closeDb(UnifiedStaticType.READ_DATABASE);
				}
			} catch (Exception e) {
				e.printStackTrace();
				ExceptionLog.writeLog("StatisticsUnsendDataCount",
						e.getMessage());
			}
		}
		return count;
	}

	public int StatisticsScanDataCount(EnumTableNames currentStatus, String data) {
		int count = 0;
		if (currentStatus.ordinal() < EnumTableNames.values().length) {
			try {
				synchronized (UnifiedStaticType.DATABASE_SYNCHRONIZED) {

					String tableName = currentStatus.getTableName();

					String cmd = ("select count(*) from " + tableName + " where scan_date = ? and metadata='1'");
					Cursor c = getCursor(UnifiedStaticType.READ_DATABASE, cmd,
							new String[] { data });
					if (c != null) {
						if (c.moveToFirst()) {
							count = c.getInt(0);
						}
						closeCursor(c);
					}
					closeDb(UnifiedStaticType.READ_DATABASE);
				}
			} catch (Exception e) {
				e.printStackTrace();
				ExceptionLog.writeLog("StatisticsUnsendDataCount",
						e.getMessage());
			}
		}
		return count;
	}

	/**
	 * 改变字符串长度
	 * 
	 * @param s
	 * @param length
	 * @return
	 */
	public String plusString(String s, int length) {
		int primaryLength = s.getBytes().length;
		if (primaryLength >= length) {
			return s.substring(0, length);
		}
		int left = length - primaryLength;
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for (int i = 0; i < left; i++) {
			sb.append(" ");
		}
		return sb.toString();
	}

	public String getImageString(String path) throws IOException {
		byte[] buffer = new byte[100 * 1024];
		File file = new File(path.substring(1));
		InputStream inputStream = new FileInputStream(file);
		int len = -1, offset = 0;
		BufferedInputStream bufferStream = new BufferedInputStream(inputStream);
		while ((len = bufferStream.read(buffer, offset, buffer.length - offset)) > 0) {
			offset += len;
		}

		String base64 = Base64
				.encodeToString(buffer, 0, offset, Base64.DEFAULT);
		return base64;
	}

	public int getUnsendDataCount() {
		int count = 0;
		int tabCount = 0;
		ProcessTableData tableData = new ProcessTableData();
		tabCount = tableData.getUploadMaxItem();
		while (tabCount > 0) {
			count += StatisticsUnsendDataCount(EnumTableNames.values()[tableData
					.getProcessUploadData(tabCount - 1, 1)]);

			tabCount--;
		}
		return count;
	}

	public int getUnsendDataCountNowDay() {
		int count = 0;
		int tabCount = 0;
		ProcessTableData tableData = new ProcessTableData();
		tabCount = tableData.getUploadMaxItem();
		while (tabCount > 0) {
			count += StatisticsUnsendDataCount(EnumTableNames.values()[tableData
					.getProcessUploadData(tabCount - 1, 1)]);

			tabCount--;
		}
		return count;
	}

	public List<UploadInfoKey> getListCode() {
		return uploadInfoKeys;
	}
}
